/*
 * Motor_Driver.c
 *
 * Created: 1/23/2013 2:25:31 PM
 *  Author: Alexander
 */ 



#include "Motor_Driver.h"



void MotorInit()
{
	DDRD |= (1<<PD0) | (1<<PD1) | (1<<PD2);				// PD0 = motor/ PD1 = sol / PD2 = INVERT / PD3 are both status flags
	PORTD |= (1<<PD3);								// Pull up for both status flags	
}

void MotorOnForward()
{
	PORTD &= ~(1<<PD2);									// This is assuming when INV is low the motor pumps forward!
	PORTD |= ((1<<PD1) |(1<<PD2));
}

void MotorOnBack()
{
	PORTD |= (1<<PD2);
	PORTD |= ((1<<PD1) |(1<<PD2));
}

void MotorOff()
{
	PORTD &= ~((1<<PD1) |(1<<PD2));
}

// if the status flag gets pulled low then there is a problem!!
//returns true if the flags gets raised LOW
bool StatusProblem()
{
	return (bit_is_clear(PIND,PD3));
}